package com.wg.db.convert;

import cn.hutool.core.util.StrUtil;

import java.util.HashSet;
import java.util.Set;

/**
 * @author 少爷123
 */
public class IntSetConvert implements IConvert<Set<Integer>> {
    @Override
    public Set<Integer> parseObject(Object obj) {
        if (!(obj instanceof String)) {
            return new HashSet<>();
        }

        String str = (String) obj;
        if (StrUtil.isEmpty(str)) {
            return new HashSet<>();
        }

        Set<Integer> integerSet = new HashSet<>(32);
        int[] array = StrUtil.splitToInt(str, ",");
        for (int value : array) {
            integerSet.add(value);
        }
        return integerSet;
    }
}
